#定义page，继承object中的元素
from appium.webdriver.common.appiumby import AppiumBy
from selenium.webdriver.common.devtools.v85.css import Value

from base.base_object import Authorize_object



class Authorize_page(Authorize_object):
    #定位一个元素的点击方法
    def privacy_agree_click(self,driver):
    # 把元素定位方式传进去AppiumBy.XPATH
    # 把元素定位值 传进去（object中封装的属性值）
        return self.click_new(driver=driver,by=AppiumBy.XPATH,value= self.privacy_agree_button())

    def authorize_agree_click(self,driver):
        return self.click_new(driver=driver,by=AppiumBy.XPATH,value=self.authrize_agree_button())

    def ad_close_click(self,driver):
        return self.click_new(driver=driver,by=AppiumBy.XPATH,value= self.ad_close_button())

    #将3步授权操作组装到一起
    def authorize_step(self,driver):
        self.privacy_agree_click(driver)
        self.authorize_agree_click(driver)
        self.ad_close_click(driver)



if  __name__ == '__main__':
    # 导入打开app的方法
    from config.comm_driver import CommonDriver
    dr = CommonDriver().get_driver()
    # 调用page中的 元素点击操作
    Authorize_page().authorize_step(dr)
    Authorize_page().click_new(dr,AppiumBy.XPATH,'//android.widget.TextView[@text=""]')
    Authorize_page().send_keys_new(dr,AppiumBy.ID,'com.dangdang.buy2:id/et_search','123456')
    Authorize_page().send_keys_new(dr,AppiumBy.ID,'com.dangdang.buy2:id/et_search','789789')
